﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using App.Data;
using App.Core.Extensions;
using System.Text;

public partial class UserControls_Footer : BaseUserControl
{
    public String NewsLetterTextBoxClientID { get { return txtNewsletter.ClientID; } }
    protected void Page_Load(object sender, EventArgs e)
    {
        BindFooter();
    }
    protected void BindFooter()
    {
        String itemsHtml = @"   <div class='FooterLinkBox'>
                                    <div class='FooterCategoryHeading'>{0}</div>
                                    {1}        
                                </div>";
        //int[] excludeIDs = { 1, 3, 6, 7};///Exclude Developer, Individual, And Load Providers for Service Provider Links
        BtcHousingEntities context = new BtcHousingEntities();
        var parentBusinessTypes = (from P in context.BusinessTypes where P.ParentID == null && ConfigReader.ServiceProviderBusinessTypeIDs.Contains(P.ID) select P).OrderBy(O => O.SortOrder).ToList();        
        StringBuilder output = new StringBuilder(100);
        foreach (BusinessType parentBusinessType in parentBusinessTypes)
        {            
            StringBuilder sb = new StringBuilder(10);
            foreach (BusinessType childBusinessType in parentBusinessType.ChildBusinessTypes)
            {
                sb.AppendFormat("<a href='/Pages/Public/CompanyList.aspx?{0}={1}'>{2}</a><br />", AppConstants.QueryString.BUSINESS_TYPE_ID, childBusinessType.ID, childBusinessType.ShortName.HtmlEncode());
            }            
            output.AppendFormat(itemsHtml, parentBusinessType.ShortName.HtmlEncode(), sb.ToString());
        }
        ltrLinks.Text = output.ToString();
    }
}